<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>工厂模式</title>
</head>
<body>
  <script>
    function createPerson(name, age, job) {
      const o = new Object();
      o.name = name;
      o.age = age;
      o.job = job;
      o.sayName = function() {
        console.log(this.name);
      };
      return o;
    }

    const person1 = createPerson("Nicholas", 29, "Sofeware Enginner");
    const person2 = createPerson("Greg", 27, "Doctor");
  </script>
</body>
</html>